/**
 * CalculateType.java 
 * Copyright © 2015-3015, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2014年11月2日
 */
package com.pshare.artemis.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 数学计算类型
 */
public enum CalculateType {
	
	ADD(1, "增加"), SUBSTRACT(2, "扣除");

	private int code;
	private String name;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	private CalculateType(int code, String name) {
		this.code = code;
		this.name = name;
	}

	public static boolean codeOf(int code) {
		for (CalculateType orderStatus : CalculateType.values()) {
			if (orderStatus.getCode() == code) {
				return true;
			}
		}
		return false;
	}

	public static String getName(int code) {
		for (CalculateType orderStatus : CalculateType.values()) {
			if (orderStatus.getCode() == code) {
				return orderStatus.getName();
			}
		}
		return "";
	}
	
	public static Map<Integer, String> getAll() {
		Map<Integer, String> map = new HashMap<Integer, String>();
		for (CalculateType em : CalculateType.values()) {
			Integer code = em.getCode();
			map.put(code, em.getName(code));
		}
		return map;
	}

}
